<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="130px">
     <!-- <el-form-item label="公司名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司代码" prop="factoryCode">
        <el-input
          v-model="queryParams.factoryCode"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="出库单号" prop="danhao">
        <el-input
          v-model="queryParams.danhao"
          placeholder="请输入出库单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库类型" prop="chukuType">
        <el-select v-model="queryParams.chukuType" placeholder="请选择出库类型" clearable>
          <el-option
            v-for="dict in dict.type.chuku_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="订单类型" prop="orderType">
        <el-select v-model="queryParams.orderType" placeholder="请选择订单类型" clearable>
          <el-option
            v-for="dict in dict.type.order_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="销售订单编号" prop="orderDanhao">
        <el-input
          v-model="queryParams.orderDanhao"
          placeholder="请输入销售订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractCode">
        <el-input
          v-model="queryParams.contractCode"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="订单数量" prop="contractNum">
        <el-input
          v-model="queryParams.contractNum"
          placeholder="请输入订单数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划出库数量" prop="jhckNum">
        <el-input
          v-model="queryParams.jhckNum"
          placeholder="请输入计划出库数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际出库数量" prop="ckNum">
        <el-input
          v-model="queryParams.ckNum"
          placeholder="请输入实际出库数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
   <!--   <el-form-item label="出库日期" prop="chukuDate">
        <el-date-picker clearable
          v-model="queryParams.chukuDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择出库日期">
        </el-date-picker>
      </el-form-item>-->
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称（英文）" prop="itemNameEn">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称（英文）"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号" prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子编号" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料子编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入物料单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次" prop="lot">
        <el-input
          v-model="queryParams.lot"
          placeholder="请输入批次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
   <!--   <el-form-item label="供应商" prop="supplyId">
        <el-input
          v-model="queryParams.supplyId"
          placeholder="请输入供应商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplyName">
        <el-input
          v-model="queryParams.supplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
     <!-- <el-form-item label="仓库编号" prop="stockId">
        <el-input
          v-model="queryParams.stockId"
          placeholder="请输入仓库编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库名称" prop="stockName">
        <el-input
          v-model="queryParams.stockName"
          placeholder="请输入仓库名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库区编码" prop="kuquCode">
        <el-input
          v-model="queryParams.kuquCode"
          placeholder="请输入库区编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库区名称" prop="kuquName">
        <el-input
          v-model="queryParams.kuquName"
          placeholder="请输入库区名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="库位编码" prop="kuweiCode">
        <el-input
          v-model="queryParams.kuweiCode"
          placeholder="请输入库位编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收仓库" prop="receivingStockId">
        <el-input
          v-model="queryParams.receivingStockId"
          placeholder="请输入接收仓库"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编码" prop="txm">
        <el-input
          v-model="queryParams.txm"
          placeholder="请输入设备编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="物料编码" prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入物料编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
    <!--  <el-form-item label="价格" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入价格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总价" prop="totalPrice">
        <el-input
          v-model="queryParams.totalPrice"
          placeholder="请输入总价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单价" prop="unitPrice">
        <el-input
          v-model="queryParams.unitPrice"
          placeholder="请输入单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
   <!--   <el-form-item label="物料类型id" prop="classId">
        <el-input
          v-model="queryParams.classId"
          placeholder="请输入物料类型id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
    <!--  <el-form-item label="物料类型" prop="className">
        <el-input
          v-model="queryParams.className"
          placeholder="请输入物料类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
     <!-- <el-form-item label="托管标识" prop="isTuoguan">
        <el-input
          v-model="queryParams.isTuoguan"
          placeholder="请输入托管标识"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="质量状态" prop="qualityState">
        <el-input
          v-model="queryParams.qualityState"
          placeholder="请输入质量状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
     <!-- <el-form-item label="制造商编码" prop="makerCode">
        <el-input
          v-model="queryParams.makerCode"
          placeholder="请输入制造商编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造商名称" prop="makerName">
        <el-input
          v-model="queryParams.makerName"
          placeholder="请输入制造商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="尺寸" prop="size">
        <el-input
          v-model="queryParams.size"
          placeholder="请输入尺寸"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单重" prop="singleWeight">
        <el-input
          v-model="queryParams.singleWeight"
          placeholder="请输入单重"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总重" prop="totalWeight">
        <el-input
          v-model="queryParams.totalWeight"
          placeholder="请输入总重"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="使用状态" prop="useState">
        <el-input
          v-model="queryParams.useState"
          placeholder="请输入使用状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="颜色" prop="color">
        <el-input
          v-model="queryParams.color"
          placeholder="请输入颜色"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="花纹" prop="figure">
        <el-input
          v-model="queryParams.figure"
          placeholder="请输入花纹"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材质" prop="caizhi">
        <el-input
          v-model="queryParams.caizhi"
          placeholder="请输入材质"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条形码" prop="txm">
        <el-input
          v-model="queryParams.txm"
          placeholder="请输入条形码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="托盘码" prop="tpm">
        <el-input
          v-model="queryParams.tpm"
          placeholder="请输入托盘码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="配送条形码" prop="pstxm">
        <el-input
          v-model="queryParams.pstxm"
          placeholder="请输入配送条形码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="配送时间" prop="psTime">
        <el-date-picker clearable
          v-model="queryParams.psTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择配送时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="组别" prop="zubie">
        <el-input
          v-model="queryParams.zubie"
          placeholder="请输入组别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拣货人" prop="pickingName">
        <el-input
          v-model="queryParams.pickingName"
          placeholder="请输入拣货人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拣货工段位" prop="pickingSegment">
        <el-input
          v-model="queryParams.pickingSegment"
          placeholder="请输入拣货工段位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拣货时间" prop="pickingTime">
        <el-date-picker clearable
          v-model="queryParams.pickingTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择拣货时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="条码打印次数" prop="txmPrintNum">
        <el-input
          v-model="queryParams.txmPrintNum"
          placeholder="请输入条码打印次数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库单打印次数" prop="ckPrintNum">
        <el-input
          v-model="queryParams.ckPrintNum"
          placeholder="请输入出库单打印次数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="器具号" prop="utensilNo">
        <el-input
          v-model="queryParams.utensilNo"
          placeholder="请输入器具号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="SAP凭证" prop="sapProof">
        <el-input
          v-model="queryParams.sapProof"
          placeholder="请输入SAP凭证"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="ckState">
        <el-input
          v-model="queryParams.ckState"
          placeholder="请输入状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收入库回写状态" prop="zzhxState">
        <el-input
          v-model="queryParams.zzhxState"
          placeholder="请输入接收入库回写状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收入时间" prop="zzrkTime">
        <el-date-picker clearable
          v-model="queryParams.zzrkTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择接收入时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="接收入库备注" prop="zzrkRemark">
        <el-input
          v-model="queryParams.zzrkRemark"
          placeholder="请输入接收入库备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收入库人" prop="zzrkName">
        <el-input
          v-model="queryParams.zzrkName"
          placeholder="请输入接收入库人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收入库数" prop="zzrkNum">
        <el-input
          v-model="queryParams.zzrkNum"
          placeholder="请输入接收入库数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:chukuInfo:add']"
        >手动出库</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleZxChuKu"
          v-hasPermi="['business:chukuInfo:zhixing']"
        >执行出库</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:chukuInfo:remove']"
        >撤销</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:chukuInfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="chukuInfoList" @selection-change="handleSelectionChange" :row-class-name="tableRowClassName">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
<!--      <el-table-column label="姓名" align="center" prop="createBy" />-->
      <el-table-column label="出库单号" width="130" align="center" prop="danhao" />
      <el-table-column label="物料名称" width="130" show-overflow-tooltip align="center" prop="itemName" />
      <el-table-column label="物料名称（英文）" width="130" show-overflow-tooltip align="center" prop="itemNameEn" />
      <el-table-column label="物料编号"  width="200" show-overflow-tooltip align="center" prop="itemCode" />
      <el-table-column label="物料子编号" width="200" show-overflow-tooltip  align="center" prop="itemId" />
      <el-table-column label="规格型号" width="130" show-overflow-tooltip align="center" prop="spec" />
      <el-table-column label="物料单位" align="center" prop="unit" />
      <el-table-column label="批次" width="100" align="center" prop="lot" />
      <el-table-column label="计划出库数量" width="130" align="center" prop="jhckNum" />
      <el-table-column label="实际出库数量" width="130" align="center" prop="ckNum" />
      <el-table-column label="仓库编号" width="150" show-overflow-tooltip align="center" prop="stockId" />
      <el-table-column label="仓库名称" width="150" show-overflow-tooltip align="center" prop="stockName" />
      <el-table-column label="库区编码" width="150" show-overflow-tooltip align="center" prop="kuquCode" />
      <el-table-column label="库区名称" width="150" show-overflow-tooltip align="center" prop="kuquName" />
      <el-table-column label="库位编码" width="130" show-overflow-tooltip align="center" prop="kuweiCode" />
      <el-table-column label="接收仓库" width="130" show-overflow-tooltip align="center" prop="receivingStockId" />
      <el-table-column label="客户名称" width="150" show-overflow-tooltip align="center" prop="clientName" />
      <el-table-column label="设备编码" width="130" show-overflow-tooltip align="center" prop="txm" />
      <el-table-column label="联系人" align="center" prop="pickingName" />
      <el-table-column label="联系电话" width="130" align="center" prop="pickingSegment" />
      <el-table-column label="出库日期" align="center" prop="chukuDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.chukuDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="出库类型" width="100" align="center" prop="chukuType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.chuku_type" :value="scope.row.chukuType"/>
        </template>
      </el-table-column>
      <el-table-column label="物料类型" align="center" prop="className" />
<!--      <el-table-column label="出库原因" align="center" prop="zubie" />-->
      <el-table-column label="订单类型" width="100" align="center" prop="orderType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.order_type" :value="scope.row.orderType"/>
        </template>
      </el-table-column>
      <el-table-column label="订单数量" align="center" prop="contractNum" />
      <el-table-column label="销售订单编号" width="150" show-overflow-tooltip align="center" prop="orderDanhao" />
      <el-table-column label="合同编号" width="150" show-overflow-tooltip align="center" prop="contractCode" />
      <el-table-column label="计划号" width="130" show-overflow-tooltip align="center" prop="planId" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="总价" align="center" prop="totalPrice" />
      <el-table-column label="托管标识" align="center" prop="isTuoguan" />
      <el-table-column label="质量状态" align="center" prop="qualityState" />
      <el-table-column label="供应商编码" width="130" show-overflow-tooltip align="center" prop="supplyCode" />
      <el-table-column label="供应商名称" width="130" show-overflow-tooltip align="                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           " prop="supplyName" />
      <el-table-column label="制造商编码" width="130" show-overflow-tooltip align="center" prop="makerCode" />
      <el-table-column label="制造商名称" width="130" show-overflow-tooltip align="center" prop="makerName" />
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="单重" align="center" prop="singleWeight" />
      <el-table-column label="总重" align="center" prop="totalWeight" />
      <el-table-column label="使用状态" align="center" prop="useState" />
      <el-table-column label="颜色" align="center" prop="color" />
      <el-table-column label="花纹" align="center" prop="figure" />
      <el-table-column label="材质" align="center" prop="caizhi" />
      <el-table-column label="托盘码" width="130" show-overflow-tooltip align="center" prop="tpm" />
      <el-table-column label="配送条形码" width="130" show-overflow-tooltip align="center" prop="pstxm" />
      <el-table-column label="配送时间" align="center" prop="psTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.psTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="组别" align="center" prop="zubie" show-overflow-tooltip />
      <el-table-column label="拣货人" align="center" prop="pickingName" />
      <el-table-column label="拣货工段位" width="130" align="center" prop="pickingSegment" />
      <el-table-column label="拣货时间" align="center" prop="pickingTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.pickingTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="条码打印次数" width="130" align="center" prop="txmPrintNum" />
      <el-table-column label="出库单打印次数" width="130" align="center" prop="ckPrintNum" />
      <el-table-column label="器具号" width="130" show-overflow-tooltip align="center" prop="utensilNo" />
      <el-table-column label="SAP凭证" width="130" show-overflow-tooltip align="center" prop="sapProof" />
      <el-table-column label="状态" width="130" show-overflow-tooltip align="center" prop="ckState" />
<!--      <el-table-column label="接收单位" width="130" show-overflow-tooltip align="center" prop="receivingUnit" />-->
      <el-table-column label="接收入库回写状态" width="130" show-overflow-tooltip align="center" prop="zzhxState" />
      <el-table-column label="接收入时间" align="center" prop="zzrkTime" width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.zzrkTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="接收入库备注" width="130" show-overflow-tooltip align="center" prop="zzrkRemark" />
      <el-table-column label="接收入库人" width="130" align="center" prop="zzrkName" />
      <el-table-column label="接收入库数" width="130"  align="center" prop="zzrkNum" />
      <el-table-column label="创建时间" width="160" align="center" prop="createTime" />
      <el-table-column label="创建者" align="center" prop="createBy" />
      <el-table-column label="更新时间" width="160" align="center" prop="updateTime" />
      <el-table-column label="出库人" align="center" prop="updateBy" />
      <el-table-column label="备注" width="150" show-overflow-tooltip align="center" prop="remark" />
      <el-table-column label="操作" fixed="right" width="180" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-circle-check"
            v-if="scope.row.ckState != 1"
            @click="handleZxChuKu(scope.row)"
            v-hasPermi="['business:chukuInfo:zhixing']"
          >执行</el-button>
         <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-if="scope.row.ckState != 1"
            v-hasPermi="['business:chukuInfo:edit']"
          >修改</el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-if="scope.row.ckState != 1"
            v-hasPermi="['business:chukuInfo:remove']"
          >撤销</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改出库单对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="1600px" append-to-body>
      <el-form ref="form" style="margin-top: -25px;" :model="form" :rules="rules" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item  label="出库类型" prop="chukuType">
              <el-select @change="handChangeChukuType"  v-model="form.chukuType" placeholder="请选择出库类型">
                <el-option
                  v-for="dict in dict.type.chuku_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出库日期" prop="chukuDate">
              <el-date-picker clearable
                              v-model="form.chukuDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择出库日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单类型" prop="orderType">
              <el-select v-model="form.orderType" placeholder="请选择订单类型">
                <el-option
                  v-for="dict in dict.type.order_type"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>

          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="销售订单编号" prop="orderDanhao">
              <el-input v-model="form.orderDanhao" placeholder="请输入销售订单编号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同编号" prop="contractCode">
              <el-input v-model="form.contractCode" placeholder="请输入合同编号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <!--<el-form-item label="客户名称" prop="clientCode">
              <el-select @change="nameSelect" filterable  :clearable="true"  v-model="form.clientCode" placeholder="请选择客户名称">
                <el-option
                  v-for="item in hbList"
                  :key="item.clientCode"
                  :label="item.clientName"
                  :value="item.clientCode">
                  <span style="float: left">{{ item.clientName }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.clientCode }}</span>
                </el-option>
              </el-select>
            </el-form-item>-->
            <el-form-item label="客户名称" prop="clientName">
              <el-input v-model="form.clientName" placeholder="请输入客户名称" />
            </el-form-item>
          </el-col>
         <!-- <el-col :span="8">
             <el-form-item label="领料人" prop="llName">
               <el-input v-model="form.llName" placeholder="请输入领料人" />
             </el-form-item>
          </el-col>-->
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="设备编码" prop="txm">
              <el-input v-model="form.clientName" placeholder="请输入设备编码" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系人" prop="pickingName">
              <el-input v-model="form.clientName" placeholder="请输入联系人" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系电话" prop="pickingSegment">
              <el-input v-model="form.clientName" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
         <!-- <el-col :span="8">
            <el-form-item label="接收单位" prop="receivingUnit">
              <treeselect @select="handleSelect"  v-model="form.receivingUnit" :clearable="true" :options="deptOptions" :show-count="true" placeholder="请选择接收单位" />
            </el-form-item>
          </el-col>-->
        </el-row>
    <!--    <el-row>
          <el-col :span="8">
            <el-form-item label="拣货人" prop="pickingName">
              <el-input v-model="form.pickingName" placeholder="请输入拣货人" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="拣货工段位" prop="pickingSegment">
              <el-input v-model="form.pickingSegment" placeholder="请输入拣货工段位" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="拣货时间" prop="pickingTime">
              <el-date-picker clearable
                              v-model="form.pickingTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择拣货时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>-->
        <el-row>
          <el-col :span="8">
            <el-form-item label="接收仓库" prop="receivingStockId">
              <!-- <el-select @change="ckChange"   v-model="form.receivingStockId" placeholder="请选择接收仓库" clearable>
                 <el-option
                   v-for="dict in warehouseinfo"
                   :key="dict.stockCode"
                   :label="dict.stockName"
                   :value="dict.stockCode"
                 />
               </el-select>-->
              <el-select @change="ckChange"  filterable  v-model="form.receivingStockId" placeholder="请选择接收仓库" clearable>
                <el-option
                  v-for="dict in warehouseinfo"
                  :key="dict.kuweiJmCode"
                  :label="dict.kuweiJmCode"
                  :value="dict.kuweiJmCode"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出库原因" prop="zubie">
              <el-input v-model="form.zubie" placeholder="请输出库原因" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="备注" prop="remark">
              <el-input  type="textarea" v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <ChukuDetailAdd :getForm="form" ref="chukuinfoAdd"></ChukuDetailAdd>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <div style="width: 100%;display: none">
      <div style="width: 100%;padding-top:30px;font-size: 20px;" ref="printDan">
        <div style="width: 50%;text-align: center;display: block;float: left;margin-bottom: 20px" >
          <div style="display: inline-block;margin-bottom: 10px" class="qrcode" ref="qrCodeUrl"></div>
          <div>{{ckDan}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { listChukuInfo, getChukuInfo, delChukuInfo, addChukuInfo, updateChukuInfo,zhixingChuku} from "@/api/business/chukuInfo";
import {lisAllFiles} from "@/api/sales/clientFiles";
import { getWarehouseInfoByDeptId } from "@/api/base/warehouseinfo";
import { getListWarehouseinfo } from "@/api/base/warehouseinfo";
import { listWarehouseinfoKuweiAll} from "@/api/base/warehouseinfoKuwei";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import ChukuDetailAdd from './chukuinfoAdd';
import QRCode from "qrcodejs2";
import print from 'print-js';

export default {
  components: {
    ChukuDetailAdd,Treeselect
  },
  name: "ChukuInfo",
  dicts: ['order_type', 'chuku_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 出库单表格数据
      chukuInfoList: [],
      warehouseinfo:[],
      hbList:[],
      deptOptions: undefined,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      ckDan:'',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        chukuType: null,
        orderType: null,
        orderDanhao: null,
        contractCode: null,
        contractNum: null,
        jhckNum: null,
        ckNum: null,
        chukuDate: null,
        itemName: null,
        itemNameEn: null,
        itemId: null,
        spec: null,
        unit: null,
        lot: null,
        supplyId: null,
        supplyName: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        itemCode: null,
        price: null,
        totalPrice: null,
        unitPrice: null,
        classId: null,
        className: null,
        isTuoguan: null,
        qualityState: null,
        makerCode: null,
        makerName: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        txm: null,
        tpm: null,
        pstxm: null,
        psTime: null,
        zubie: null,
        pickingName: null,
        pickingSegment: null,
        pickingTime: null,
        txmPrintNum: null,
        ckPrintNum: null,
        utensilNo: null,
        sapProof: null,
        ckState: null,
        zzhxState: null,
        zzrkTime: null,
        zzrkRemark: null,
        zzrkName: null,
        zzrkNum: null,
        clientName: null,
        receivingStockId: null,
      },
      // 表单参数
      form: {
        infoList:[]
      },
      // 表单校验
      rules: {
        chukuType: [
          { required: true, message: "请选择出库类型", trigger: "blur" }
        ],
        chukuDate: [
          { required: true, message: "请输入出库日期", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
    lisAllFiles().then(response => {
      this.hbList = response.rows;
    });
    /* getListWarehouseinfo().then(response => {
      this.warehouseinfo = response.data;
    });*/
    listWarehouseinfoKuweiAll().then(response => {
      this.warehouseinfo = response.data;
    });
  },
  methods: {
    printChu(){
      let id = this.ids[0]

        getChukuInfo(id).then(res=>{
          this.$nextTick(()=>{
            this.ckDan = res.data.danhao
            let ckDan = res.data.danhao
            this.$refs.qrCodeUrl.innerHTML="";
            new QRCode(this.$refs.qrCodeUrl, {
              text: ckDan, //二维码内容
              width: 150,
              height: 150,
            })
          })

          setTimeout(()=>{
            this.priDan()
          },200)
        })
    },
    priDan(){

      const style = '@page { margin:0 } ' +'@media print { #title{ font-size:40px};#title1{ font-size:40px }  ' ;
      printJS({
        printable:this.$refs.printDan,
        type:'html',
        header:'',
        targetStyles:['*'],
        scanStyles: false,
        style:style,
        onPrintDialogClose: () => {
          console.log('弹窗关闭');
        },
        onLoadingEnd:()=>{
          console.log('加载完毕')
        }
      })
    },
    tableRowClassName({row, rowIndex}) {
      if (row.ckState == 0) {
        return 'warning-row';
      } else{
        return '';
      }

    },
    /** 查询出库单列表 */
    getList() {
      this.loading = true;
      listChukuInfo(this.queryParams).then(response => {
        this.chukuInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    nameSelect(e){
      let result = this.hbList.find(item => item.clientCode ==e)
      this.form.clientName = result.clientName
      /* this.warehouseinfo =[];
       this.form.receivingStockId=null;
       getWarehouseInfoByDeptId(selectedNodes.id).then(response => {
         this.warehouseinfo = response.data;
       });*/
    },
    handleSelect(selectedNodes) {
      this.warehouseinfo =[];
      this.form.receivingStockId=null;
      getWarehouseInfoByDeptId(selectedNodes.id).then(response => {
        this.warehouseinfo = response.data;
      });
    },
    ckChange(){
      this.$forceUpdate();
    },
    handleClear(){
      alert("清楚了")
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        chukuType: null,
        orderType: null,
        orderDanhao: null,
        contractCode: null,
        contractNum: null,
        jhckNum: null,
        ckNum: null,
        chukuDate: new Date(),
        itemName: null,
        itemNameEn: null,
        itemId: null,
        spec: null,
        unit: null,
        lot: null,
        supplyId: null,
        supplyName: null,
        stockId: null,
        stockName: null,
        kuquCode: null,
        kuquName: null,
        kuweiCode: null,
        itemCode: null,
        price: null,
        totalPrice: null,
        unitPrice: null,
        classId: null,
        className: null,
        isTuoguan: null,
        qualityState: null,
        makerCode: null,
        makerName: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        txm: null,
        tpm: null,
        pstxm: null,
        psTime: null,
        zubie: null,
        pickingName: null,
        pickingSegment: null,
        pickingTime:  new Date(),
        txmPrintNum: null,
        ckPrintNum: null,
        utensilNo: null,
        sapProof: null,
        ckState: null,
        zzhxState: null,
        zzrkTime: null,
        zzrkRemark: null,
        zzrkName: null,
        zzrkNum: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        receivingUnit: null,
        receivingStockId: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    handChangeChukuType(value){
      this.reset();
      this.form.chukuType=value;
      this.$refs.chukuinfoAdd.chukuinfoAddList=[];
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "手动出库";
      setTimeout(() => {
        this.$refs.chukuinfoAdd.chukuInfoAddlistReset();
      }, 10);
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getChukuInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改出库单";
        setTimeout(() => {
          this.$refs.chukuinfoAdd.chukuInfoUpdatelistReset(response.data);
        }, 10);
      });
    },
    /*执行入库*/
    handleZxChuKu(row){
      const id = row.id || this.ids
      this.$modal.confirm('是否确认执行出库吗?').then(function() {
        return zhixingChuku(id);
      }).then(() => {
        this.getList();
        this.$modal.alertSuccess("出库成功");
      }).catch(() => {});
    },
    /** 提交按钮 */
    submitForm() {
      let chukuinfoAddList= this.$refs.chukuinfoAdd.chukuinfoAddList;
      if(chukuinfoAddList.length==0){
        this.$modal.alertWarning('请选择需要出库的物料!')
        return;
      }
      for(var i=0;i<chukuinfoAddList.length;i++){
        if(chukuinfoAddList[i].ckNum==''||chukuinfoAddList[i].ckNum==null||chukuinfoAddList[i].ckNum==undefined|| chukuinfoAddList[i].ckNum<=0){
          this.$modal.alertWarning('出库数量不能为空或为0')
          return;
        }
        /*  if(chukuinfoAddList[i].unitPrice==''||chukuinfoAddList[i].unitPrice==null||chukuinfoAddList[i].unitPrice==undefined){
            this.$modal.alertWarning('单价不能为空')
            return;
          }*/
        if(chukuinfoAddList[i].ckNum>chukuinfoAddList[i].kyNum){
          this.$modal.alertWarning('出库数量不能大于可用库存数量')
          return;
        }

      }
      if(this.form.chukuType=='4' || this.form.chukuType=='10' || this.form.chukuType=='12'){
        // if(this.form.receivingUnit==null || this.form.receivingUnit==""){
        //   this.$modal.alertWarning('请选择接收单位')
        //   return;
        // }
        if(this.form.receivingStockId==null || this.form.receivingStockId==""){
          this.$modal.alertWarning('请选择接收仓库')
          return;
        }
      }
      this.form.infoList=chukuinfoAddList;
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateChukuInfo(this.form).then(response => {
              this.$modal.alertSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addChukuInfo(this.form).then(response => {
              this.$modal.alertSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 撤销按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认撤销出库单编号为"' + ids + '"的数据项？').then(function() {
        return delChukuInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("撤销成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/chukuInfo/export', {
        ...this.queryParams
      }, `chukuInfo_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
  ::v-deep .el-table .warning-row {
    background: #ffe4e1;
  }
</style>
